Skip to content

Expand model space for numeric ordered ChoiceParameters (#5210)#5210

Open
saitcakmak wants to merge 1 commit into
facebook:mainfrom
saitcakmak:export-D81179672
Open

Expand model space for numeric ordered ChoiceParameters (#5210)#5210
saitcakmak wants to merge 1 commit into
facebook:mainfrom
saitcakmak:export-D81179672

Conversation

@saitcakmak
Copy link
Copy Markdown
Contributor

@saitcakmak saitcakmak commented May 28, 2026

Summary:

Closes #5209.

Extends Adapter._set_model_space to expand ChoiceParameter.values for numeric ordered choice parameters whose training data falls outside the declared values list, mirroring the existing behavior for RangeParameter bounds. Previously, only RangeParameter was expanded and out-of-design choice values were filtered, which was surprising for users who expect symmetric treatment.

Expansion is gated to numeric ordered choice parameters. Unordered (one-hot-encoded) and string choice parameters are left alone because the downstream OneHot and OrderedChoiceToIntegerRange transforms would otherwise produce a transformed model space that is inconsistent with the transformed search space used at generation time, corrupting extract_search_space_digest and Adapter.parameters. With D87903513 enforcing sort_values=True for numeric ordered parameters, the gated case is safe to expand and always sortable.

Implementation notes:

  • New observed values are deduped and merged with existing p.values, then sorted before being passed to set_values. set_values (unlike ChoiceParameter.__init__) does not dedupe its input, and duplicates would corrupt the integer encodings produced downstream by OrderedChoiceToIntegerRange.
  • If a numeric ordered ChoiceParameter is declared as INT but an observed value is non-integer (e.g. 2.5), the model-space copy of the parameter is relaxed to FLOAT so the observation is preserved exactly rather than truncated by _cast_values. This is safe because _model_space is adapter-local and never persisted; the user-facing experiment.search_space is untouched. Downstream consumers of ChoiceParameter (OrderedChoiceToIntegerRange, ChoiceToNumericChoice, etc.) do not branch on INT vs FLOAT.

Differential Revision: D81179672

@meta-cla meta-cla Bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label May 28, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented May 28, 2026

@saitcakmak has exported this pull request. If you are a Meta employee, you can view the originating Diff in D81179672.

Summary:
Pull Request resolved: facebook#5210

Closes facebook#5209.

Extends `Adapter._set_model_space` to expand `ChoiceParameter.values` for numeric ordered choice parameters whose training data falls outside the declared `values` list, mirroring the existing behavior for `RangeParameter` bounds. Previously, only `RangeParameter` was expanded and out-of-design choice values were filtered, which was surprising for users who expect symmetric treatment.

Expansion is gated to numeric ordered choice parameters. Unordered (one-hot-encoded) and string choice parameters are left alone because the downstream `OneHot` and `OrderedChoiceToIntegerRange` transforms would otherwise produce a transformed model space that is inconsistent with the transformed search space used at generation time, corrupting `extract_search_space_digest` and `Adapter.parameters`. With D87903513 enforcing `sort_values=True` for numeric ordered parameters, the gated case is safe to expand and always sortable.

Implementation notes:
- New observed values are deduped and merged with existing `p.values`, then sorted before being passed to `set_values`. `set_values` (unlike `ChoiceParameter.__init__`) does not dedupe its input, and duplicates would corrupt the integer encodings produced downstream by `OrderedChoiceToIntegerRange`.
- If a numeric ordered `ChoiceParameter` is declared as `INT` but an observed value is non-integer (e.g. `2.5`), the model-space copy of the parameter is relaxed to `FLOAT` so the observation is preserved exactly rather than truncated by `_cast_values`. This is safe because `_model_space` is adapter-local and never persisted; the user-facing `experiment.search_space` is untouched. Downstream consumers of `ChoiceParameter` (`OrderedChoiceToIntegerRange`, `ChoiceToNumericChoice`, etc.) do not branch on INT vs FLOAT.

Differential Revision: D81179672
@meta-codesync meta-codesync Bot changed the title Expand model space for numeric ordered ChoiceParameters Expand model space for numeric ordered ChoiceParameters (#5210) May 28, 2026
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.51%. Comparing base (dd8b120) to head (c4bf40e).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5210   +/-   ##
=======================================
  Coverage   96.50%   96.51%           
=======================================
  Files         617      617           
  Lines       69626    69694   +68     
=======================================
+ Hits        67194    67262   +68     
  Misses       2432     2432           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Do not delete this pull request or issue due to inactivity. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: ChoiceParameters out-of-design not included in training data

2 participants